<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateActWishTreeTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('act_wish_tree', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id')->default(0)->comment('用户ID');
            $table->unsignedSmallInteger('wish_gift_id')->default(0)->comment('许愿树奖品ID');
            $table->unsignedInteger('num')->default(1)->comment('数量');
            $table->double('coin', 10, 1)->default(0.0)->comment('许愿花费金币');
            $table->unsignedTinyInteger('flag')->default(1)->comment('状态：1-有效，0-无效');
            $table->timestamps();
            $table->index('user_id', 'user_id');
            $table->index('wish_gift_id', 'wish_gift_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('act_wish_tree');
    }
}
